//niech żyją tutroki na jutubach

import java.awt.event.*;
import java.util.*;
import javax.swing.*;

/**
 *
 * @author Asia
 */
public class DeckC{
    
    public static final int Clubs=1;
    public static final int Diamonds=2;
    public static final int Hearts=3;
    public static final int Spades=4;
    
    private final String[] suitNames=new String[]
    {
     "Clubs","Diamonds","Hearts","Spades"   
    };
    
    public static final int Jack=11;
    public static final int Queen=12;
    public static final int King=13;
    public static final int Ace=14;
    
    private final String[] faceNames=new String[]
    {
      "2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"  
    };
    
    private final int deckValue;
    private final int faceValue;
    private final int suitValue;
    
    public DeckC( int deckValue)
    {
        if((deckValue)<1||(deckValue>52))
            throw new IllegalArgumentException();
        
        this.deckValue=deckValue;
        faceValue=toFaceValue(deckValue);
        suitValue=toSuitValue(deckValue);
    }
    
    public DeckC(int faceValue, int suitValue)
    {
        if((faceValue<2)||(suitValue>14))
        	throw new IllegalArgumentException();       
        
        if((suitValue<1)|| (suitValue>4))
        	throw new IllegalArgumentException(); 	

        this.faceValue=faceValue;
        this.suitValue=suitValue;
        this.deckValue=toDeckValue(faceValue,suitValue);
    }
    
    public boolean equals(Object other)
    {
    	if(!(other instanceof)Card)
    		return false;
    	
    	Card cardOther= (Card)other;
    	
    	if(deckValue != cardOther.deckValue)
    		return false;
    	
    	return true;
    }
    
    public int getDeckValue()
    {
    	return deckValue;
    }
    
    public String getFaceName()
    {
    	return faceNames[faceValue-2];
    }
    
    public int get FaceValue()
    {
    	return faceValue;
    }
    
    public String getSuitName()
    {
    	return suitNames[suitValue-1];
    }
    
    public int getSuitValue()
    {
    	return suitValue;
    }
    
    public static int toDeckValue(int faceValue, int suitValue)
    {
    	if((faceValue<2)||(suitValue>14))
    		throw new IllegalArgumentException();   

        
        if((suitValue<1)|| (suitValue>4))
        	throw new IllegalArgumentException(); 	

       int deckValue=(13*(suitValue-1))+faceValue-1;
       return deckValue;
    }
    
    public static int toFaceValue(int deckValue)
    {
    	int faceValue = (deckValue%13)+1;
    	if (faceValue==1)
    		faceValue=14;
    	
    	return faceValue;
    }
    
    public String toString()
    {
    	String string= getFaceName()+ " of " +getSuitName();
    	return string;
    }	
    
    public String toStringBrief()
    {
    	String faceBrief;
    	
    	if(faceValue<=10){
    		faceBrief=getFaceName();}
    	else{
    		faceBrief=getFaceName().substring(0,1);}
    	
    	String suitBrief=getSuitName().substring(0,1);
    	String brief=faceBrief+suitBrief;
    	return brief;
    }
    
    public static int toSuitValue(int deckValue)
    {
    	int suitValue=deckValue/13;
    	
    	if(deckValue%13 !=0)
    		suitValue++;
 
    	return suitValue;
    }
   
}